<template>
    <div class="copyright page">
        <div class="title">版权转让</div>
        <div class="filter">
            <el-form
                    :inline="true"
                    :model="formInline"
                    class="demo-form-inline"
                    size="mini"
            >
                <el-form-item label="所属分类：">
                    <el-select v-model="formInline.region" placeholder="所属分类：">
                        <el-option label="短视频" value="短视频"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="作品名称 ：">
                    <!--                    <el-select v-model="formInline.region" placeholder="状态：">-->
                    <!--                        <el-option label="短视频" value="短视频"></el-option>-->
                    <!--                    </el-select>-->
                    <el-input v-model="formInline.workName" placeholder="作品名称 "/>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="onSubmit">筛选</el-button>
                    <el-button @click.stop="reset">重置</el-button>
                </el-form-item>
            </el-form>
            <el-table :data="tableData" stripe style="width: 100%" height="400" class="table">
                <el-table-column label="序号" width="80" type="index"/>
                <el-table-column label="操作">
                    <template #default="scope">
                        <el-button size="mini" type="primary" @click.stop="to_trade(scope.row.id)" v-if="scope.row.price !=null">购买</el-button>
                        <el-button size="mini" type="primary" @click.stop="to_detail(scope.row.id)" v-else>查看</el-button>
                    </template>
                </el-table-column>
                <el-table-column prop="title" label="作品名称" width="80">
                        <template #default="scope">

                            <div style="cursor:default;">
                                {{scope.row.title}}
                            </div>

                        </template>
                </el-table-column>
                <el-table-column prop="creationTypeName" label="作品类型"/>
                <el-table-column prop="price" label="版权转让费">
                    <template #default="scope">
                        <div>{{scope.row.price == null ? '免费' : scope.row.price}}</div>
                    </template>
                </el-table-column>

                <el-table-column prop="tokenId" label="作品ID "/>
                <el-table-column prop="hashCode" label="交易Hash ">
                    <template #default="scope">
                        <span class="spanColor">{{ strTrans(scope.row.hashCode)}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="contractId" label="智能合约 ">
                    <template #default="scope">
                        <span class="spanColor">{{ strTrans(scope.row.contractId)}}</span>
                    </template>
                </el-table-column>
            </el-table>

<!--            <div style="text-align: center; margin-top: 20px">-->
<!--                <el-pagination-->
<!--                        background-->
<!--                        v-model:currentPage="currentPage1"-->
<!--                        :page-size="15"-->
<!--                        layout="prev, pager, next"-->
<!--                        :total="400"-->
<!--                        @size-change="handleSizeChange"-->
<!--                        @current-change="handleCurrentChange"-->
<!--                >-->
<!--                </el-pagination>-->
<!--            </div>-->

        </div>

    </div>
</template>
<script>
    import {ScriptWritingBQZRList} from "../../api/ScriptWriting";

    export default {
        data() {
            return {
                currentPage1: 1,
                formInline: {
                    region: '短视频',
                    workName: ''
                },
                tableData: [
                    {
                        scriptWritingTitle: 'haha',
                        tradeId: "haha",
                        buyerID: 'ahahah',
                        price: "aaa",
                        createTime: 'aaa',
                    },
                ],
                description:{}
            };
        },

        created() {

            ScriptWritingBQZRList({creationTypeId: 1}).then(res => {
                this.tableData = res.data.list
                console.log('aaaaaaa', this.tableData)
            })

        },

        methods: {
            reset() {
                this.formInline.workName = ''
                ScriptWritingBQZRList({creationTypeId: 1}).then(res => {
                    this.tableData = res.data.list
                    console.log('aaaaaaa', this.tableData)
                })
            },
            strTrans(d) {
                if (d == null || d == undefined) {
                    return ' '
                } else {
                    return (
                        d.substring(0, 6) + "..." + d.substring(d.length - 5, d.length - 1)
                    );
                }
            },
            onSubmit() {
                if (this.formInline.workName == '' || this.formInline.workName == null) {

                    ScriptWritingBQZRList({creationTypeId: 1}).then(res => {
                        this.tableData = res.data.list
                        console.log('aaaaaaa', this.tableData)
                    })

                } else {

                    ScriptWritingBQZRList({creationTypeId: 1, title: this.formInline.workName}).then(res => {
                        this.tableData = res.data.list
                        console.log('aaaaaaa', this.tableData)
                    })

                }
            },
            to_trade(id){
              this.$router.push({path:'/copyright/copyrightTrade',query:{id:id}})
            },
            to_detail(id){
                this.$router.push({path:'/dsp/dspDetail',query:{id:id}})
            },
            mouseover(ev){
                console.log('mouseover',typeof ev.clientX,ev.clientY)
                this.description.display='block'
                this.description.position='fixed'
                this.description.top=(ev.clientY).toString()+"px"
                this.description.left=(ev.clientX).toString()+"px"
            },
            mouseout(ev){
                console.log('mouseover',ev.clientX,ev.clientY)
                this.description.display='none'
            },
            handleSizeChange() {
            },
            handleCurrentChange() {
            },
        },
    };
</script>
<style lang="scss" scoped>
    .copyright {
        background: #ffffff;
        box-shadow: 0px 0px 21px 0px rgba(17, 16, 16, 0.07);
        border-radius: 4px;
        margin-top: 20px;
        padding-bottom: 20px;
        margin-bottom: 50px;

        .title {
            height: 60px;
            line-height: 60px;
            text-indent: 20px;
            background: #2eb0c6;
            box-shadow: 0px 0px 21px 0px rgba(17, 16, 16, 0.07);
            font-size: 16px;
            font-weight: bold;
            color: #000000;
        }

        .filter {
            margin: 20px;
        }

        ::v-deep {
            .el-table__header-wrapper {
                th {
                    background: #f5f6f6;
                    color: #333333;
                }
            }
        }
    }

    .table {
        ::v-deep {
            .el-table__header-wrapper th {
                text-align: center;
            }
        }

        ::v-deep {
            .el-table__body td.el-table__cell {
                text-align: center;
                transition: background-color .25s ease;
            }
        }
    }

    .spanColor {
        color: #2eb0c6;
    }

    .description{
        display: none;
        position: fixed;
        z-index: 99;
        background: #f6f6f6;
        width: 100px;
        height: 100px;
        overflow: hidden;
        border: 1px solid f5f5f5;
    }
</style>
